home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / common.h < prev    next >
C/C++ Source or Header  |  2000-04-04  |  7KB  |  188 lines

  1. /*********************************************************************
  2.  
  3.   common.h
  4.  
  5.   Generic functions, mostly ROM related.
  6.  
  7. *********************************************************************/
  8.  
  9. #ifndef COMMON_H
  10. #define COMMON_H
  11.  
  12. struct RomModule
  13. {
  14.     const char *name;    /* name of the file to load */
  15.     UINT32 offset;        /* offset to load it to */
  16.     UINT32 length;        /* length of the file */
  17.     UINT32 crc;            /* standard CRC-32 checksum */
  18. };
  19.  
  20. /* there are some special cases for the above. name, offset and size all set to 0 */
  21. /* mark the end of the array. If name is 0 and the others aren't, that means "continue */
  22. /* reading the previous rom from this address". If length is 0 and offset is not 0, */
  23. /* that marks the start of a new memory region. Confused? Well, don't worry, just use */
  24. /* the macros below. */
  25.  
  26. #define ROMFLAG_MASK          0xf8000000           /* 5 bits worth of flags in the high nibble */
  27.  
  28. /* Masks for individual ROMs */
  29. #define ROMFLAG_ALTERNATE     0x80000000           /* Alternate bytes, either even or odd, or nibbles, low or high */
  30. #define ROMFLAG_WIDE          0x40000000           /* 16-bit ROM; may need byte swapping */
  31. #define ROMFLAG_SWAP          0x20000000           /* 16-bit ROM with bytes in wrong order */
  32. #define ROMFLAG_NIBBLE        0x10000000           /* Nibble-wide ROM image */
  33. #define ROMFLAG_QUAD          0x08000000           /* 32-bit data arranged as 4 interleaved 8-bit roms */
  34.  
  35. /* start of table */
  36. #define ROM_START(name) static struct RomModule rom_##name[] = {
  37. /* start of memory region */
  38. #define ROM_REGION(length,type) { 0, length, 0, type },
  39.  
  40. enum {
  41.     REGION_INVALID = 0x80,
  42.     REGION_CPU1,
  43.     REGION_CPU2,
  44.     REGION_CPU3,
  45.     REGION_CPU4,
  46.     REGION_CPU5,
  47.     REGION_CPU6,
  48.     REGION_CPU7,
  49.     REGION_CPU8,
  50.     REGION_GFX1,
  51.     REGION_GFX2,
  52.     REGION_GFX3,
  53.     REGION_GFX4,
  54.     REGION_GFX5,
  55.     REGION_GFX6,
  56.     REGION_GFX7,
  57.     REGION_GFX8,
  58.     REGION_PROMS,
  59.     REGION_SOUND1,
  60.     REGION_SOUND2,
  61.     REGION_SOUND3,
  62.     REGION_SOUND4,
  63.     REGION_SOUND5,
  64.     REGION_SOUND6,
  65.     REGION_SOUND7,
  66.     REGION_SOUND8,
  67.     REGION_USER1,
  68.     REGION_USER2,
  69.     REGION_USER3,
  70.     REGION_USER4,
  71.     REGION_USER5,
  72.     REGION_USER6,
  73.     REGION_USER7,
  74.     REGION_USER8,
  75.     REGION_MAX
  76. };
  77.  
  78. #define REGIONFLAG_MASK            0xf8000000
  79. #define REGIONFLAG_DISPOSE        0x80000000           /* Dispose of this region when done */
  80. #define REGIONFLAG_SOUNDONLY    0x40000000           /* load only if sound emulation is turned on */
  81.  
  82.  
  83. #define BADCRC( crc ) (~(crc))
  84.  
  85. /* ROM to load */
  86. #define ROM_LOAD(name,offset,length,crc) { name, offset, length, crc },
  87.  
  88. /* continue loading the previous ROM to a new address */
  89. #define ROM_CONTINUE(offset,length) { 0, offset, length, 0 },
  90. /* restart loading the previous ROM to a new address */
  91. #define ROM_RELOAD(offset,length) { (char *)-1, offset, length, 0 },
  92.  
  93. /* These are for nibble-wide ROMs, can be used with code or data */
  94. #define ROM_LOAD_NIB_LOW(name,offset,length,crc) { name, offset, (length) | ROMFLAG_NIBBLE, crc },
  95. #define ROM_LOAD_NIB_HIGH(name,offset,length,crc) { name, offset, (length) | ROMFLAG_NIBBLE | ROMFLAG_ALTERNATE, crc },
  96. #define ROM_RELOAD_NIB_LOW(offset,length) { (char *)-1, offset, (length) | ROMFLAG_NIBBLE, 0 },
  97. #define ROM_RELOAD_NIB_HIGH(offset,length) { (char *)-1, offset, (length) | ROMFLAG_NIBBLE | ROMFLAG_ALTERNATE, 0 },
  98.  
  99. /* The following ones are for code ONLY - don't use for graphics data!!! */
  100. /* load the ROM at even/odd addresses. Useful with 16 bit games */
  101. #define ROM_LOAD_EVEN(name,offset,length,crc) { name, (offset) & ~1, (length) | ROMFLAG_ALTERNATE, crc },
  102. #define ROM_RELOAD_EVEN(offset,length) { (char *)-1, (offset) & ~1, (length) | ROMFLAG_ALTERNATE, 0 },
  103. #define ROM_LOAD_ODD(name,offset,length,crc)  { name, (offset) |  1, (length) | ROMFLAG_ALTERNATE, crc },
  104. #define ROM_RELOAD_ODD(offset,length)  { (char *)-1, (offset) |  1, (length) | ROMFLAG_ALTERNATE, 0 },
  105. /* load the ROM at even/odd addresses. Useful with 16 bit games */
  106. #define ROM_LOAD_WIDE(name,offset,length,crc) { name, offset, (length) | ROMFLAG_WIDE, crc },
  107. #define ROM_RELOAD_WIDE(offset,length) { (char *)-1, offset, (length) | ROMFLAG_WIDE, 0 },
  108. #define ROM_LOAD_WIDE_SWAP(name,offset,length,crc) { name, offset, (length) | ROMFLAG_WIDE | ROMFLAG_SWAP, crc },
  109. #define ROM_RELOAD_WIDE_SWAP(offset,length) { (char *)-1, offset, (length) | ROMFLAG_WIDE | ROMFLAG_SWAP, 0 },
  110. /* Data is split between 4 roms, always use this in groups of 4! */
  111. #define ROM_LOAD_QUAD(name,offset,length,crc) { name, offset, length | ROMFLAG_QUAD, crc },
  112.  
  113. #ifdef LSB_FIRST
  114. #define ROM_LOAD_V20_EVEN    ROM_LOAD_EVEN
  115. #define ROM_RELOAD_V20_EVEN  ROM_RELOAD_EVEN
  116. #define ROM_LOAD_V20_ODD    ROM_LOAD_ODD
  117. #define ROM_RELOAD_V20_ODD   ROM_RELOAD_ODD
  118. #define ROM_LOAD_V20_WIDE    ROM_LOAD_WIDE
  119. #else
  120. #define ROM_LOAD_V20_EVEN    ROM_LOAD_ODD
  121. #define ROM_RELOAD_V20_EVEN  ROM_RELOAD_ODD
  122. #define ROM_LOAD_V20_ODD    ROM_LOAD_EVEN
  123. #define ROM_RELOAD_V20_ODD   ROM_RELOAD_EVEN
  124. #define ROM_LOAD_V20_WIDE    ROM_LOAD_WIDE_SWAP
  125. #endif
  126.  
  127. /* Use THESE ones for graphics data */
  128. #ifdef LSB_FIRST
  129. #define ROM_LOAD_GFX_EVEN    ROM_LOAD_ODD
  130. #define ROM_LOAD_GFX_ODD     ROM_LOAD_EVEN
  131. #define ROM_LOAD_GFX_SWAP    ROM_LOAD_WIDE
  132. #else
  133. #define ROM_LOAD_GFX_EVEN    ROM_LOAD_EVEN
  134. #define ROM_LOAD_GFX_ODD     ROM_LOAD_ODD
  135. #define ROM_LOAD_GFX_SWAP    ROM_LOAD_WIDE_SWAP
  136. #endif
  137.  
  138. /* end of table */
  139. #define ROM_END { 0, 0, 0, 0 } };
  140.  
  141.  
  142.  
  143. struct GameSample
  144. {
  145.     int length;
  146.     int smpfreq;
  147.     int resolution;
  148.     signed char data[1];    /* extendable */
  149. };
  150.  
  151. struct GameSamples
  152. {
  153.     int total;    /* total number of samples */
  154.     struct GameSample *sample[1];    /* extendable */
  155. };
  156.  
  157.  
  158.  
  159.  
  160. void showdisclaimer(void);
  161.  
  162. /* LBO 042898 - added coin counters */
  163. #define COIN_COUNTERS    4    /* total # of coin counters */
  164. WRITE_HANDLER( coin_counter_w );
  165. WRITE_HANDLER( coin_lockout_w );
  166. WRITE_HANDLER( coin_lockout_global_w );  /* Locks out all coin inputs */
  167.  
  168. int readroms(void);
  169. void printromlist(const struct RomModule *romp,const char *name);
  170.  
  171. /* helper function that reads samples from disk - this can be used by other */
  172. /* drivers as well (e.g. a sound chip emulator needing drum samples) */
  173. struct GameSamples *readsamples(const char **samplenames,const char *name);
  174. void freesamples(struct GameSamples *samples);
  175.  
  176. /* return a pointer to the specified memory region - num can be either an absolute */
  177. /* number, or one of the REGION_XXX identifiers defined above */
  178. unsigned char *memory_region(int num);
  179. int memory_region_length(int num);
  180. /* allocate a new memory region - num can be either an absolute */
  181. /* number, or one of the REGION_XXX identifiers defined above */
  182. int new_memory_region(int num, int length);
  183. void free_memory_region(int num);
  184.  
  185. void save_screen_snapshot(void);
  186.  
  187. #endif
  188.